package hust.music.action;

import java.util.*;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import hust.music.action.base.ActionBase;
import hust.music.entity.User;
import hust.music.service.HomePageModService;
import hust.music.service.UserModService;
import hust.music.util.DynamicInfo;

/**
 * HomePageAction
 * 
 * @author Txazo
 * @since 1.0
 */
@Controller
@Scope("session")
public class HomePageAction extends ActionBase {

	private static final long serialVersionUID = 1L;

	/** 个人主页用户Id */
	private Integer id;

	/** 关注粉丝分享数的Map */
	private Map<String, Integer> followFanShare = new HashMap<String, Integer>();
	/** 我关注的人 */
	private List<DynamicInfo> follows = new ArrayList<DynamicInfo>();
	
	private Map<String, DynamicInfo> reminds = new HashMap<String, DynamicInfo>();

	@Autowired
	private HomePageModService homePageModService;
	@Autowired
	private UserModService userModService;

	/**
	 * 个人主页
	 * 
	 * @return 逻辑视图
	 * @throws Exception
	 */
	public String homePage() throws Exception {
		User user = userModService.get(id);
		session.remove("home");
		session.put("home", user);

		followFanShare = homePageModService.getPersonalCount(user);
		follows = homePageModService.getFollow(user, 0, 14);
		reminds = homePageModService.getRemind(user, 0, 10);
		return SUCCESS;
	}
	
	public Map<String, Integer> getFollowFanShare() {
		return followFanShare;
	}

	public void setFollowFanShare(Map<String, Integer> followFanShare) {
		this.followFanShare = followFanShare;
	}

	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public List<DynamicInfo> getFollows() {
		return follows;
	}

	public void setFollows(List<DynamicInfo> follows) {
		this.follows = follows;
	}

	public Map<String, DynamicInfo> getReminds() {
		return reminds;
	}

	public void setReminds(Map<String, DynamicInfo> reminds) {
		this.reminds = reminds;
	}



}